package queue;

public class CircleQueue {
    private int[] arr;
    private int maxSize;
    private int front;
    private int rear;
    public CircleQueue(int maxSize) {
        this.maxSize = maxSize;
        arr = new int[maxSize];
        front = 0;
        rear = 0;
    }
    public boolean isEmpty() {
        return front == rear;
    }
    public boolean isFull() {
        return (rear + 1) % maxSize == front;
    }
    public void enqueue(int value) {
        if (isFull()) {
            System.out.println("Queue is full");
        }
        arr[rear] = value;
        rear = (rear + 1) % maxSize;
    }
    public int dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty");
        }
        int value = arr[front];
        front = (front + 1) % maxSize;
        return value;
    }

}
